package com.wu.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.google.common.collect.Lists;

/**
 * @Author: fei.wu
 * @Email: fei.wu@rograndec.com
 * @CreateDate: 2019-03-12
 * @Version: 1.0
 */
public class StreamDemo {

    public static void test() {
        ArrayList<Integer> list = Lists.newArrayList(1, null, 3, null, 2, 0);
        List<Integer> collect = list.stream().filter(num -> num != null).collect(Collectors.toList());
        collect.forEach(System.out::println);
    }

    public static void testObj() {
        ArrayList<StudentVO> studentVOS = Lists.newArrayList(
                new StudentVO(1, "zhang", "男"),
                new StudentVO(2, "wang", "男"),
                new StudentVO(3, "zhao", "女"),
                new StudentVO(4, "zhao", "男"));
        studentVOS.stream().filter(studentVO -> studentVO.getName().equals("zhao")).filter(studentVO -> studentVO.getSex().equals("男")).collect(Collectors.toList()).forEach(studentVO -> System.out.println(studentVO.getId() + "-" + studentVO.getName()));


    }

    public static void main(String[] args) {
        StreamDemo.testObj();
    }

}
